package com.chisheng.caa.handler;

import com.chisheng.caa.exception.CaaException;
import com.chisheng.caa.pojo.response.JsonResponse;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Caa 服务异常处理器
 */
@RestControllerAdvice
public class CaaExceptionHandler {

    @ExceptionHandler(MethodArgumentNotValidException.class)
    public JsonResponse<?> caaException(CaaException e) {
        return JsonResponse.failure(e.getCode(), e.getMessage());
    }

}
